package com.gz.controller;

import com.gz.entity.StudentQuestionTagWeights;
import com.gz.entity.Tuser;
import com.gz.service.StudentQuestionTagWeightsService;
import com.gz.vo.StudentQuestionTagWeightsVO;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import org.springframework.web.bind.annotation.*;
import org.springframework.beans.factory.annotation.Autowired;
import com.gz.vo.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import com.gz.dto.StudentQuestionTagWeightsDto;

import javax.servlet.http.HttpServletRequest;

/**
 * (StudentQuestionTagWeights)表控制层
 *
 * @author jhk
 * @since 2024-07-18 20:41:13
 */
@RestController
@RequestMapping("studentQuestionTagWeights")
@Api(value = "学生题目标签权重控制层", tags = {"学生题目标签权重控制层"})
public class StudentQuestionTagWeightsController {
    /**
     * 服务对象
     */
    @Autowired
    private StudentQuestionTagWeightsService studentQuestionTagWeightsService;

    /**
     * 分页查询
     *
     * @param dto 筛选条件
     * @return 查询结果
     */
    @ApiOperation(value = "分页查询")
    @PostMapping("/queryPage")
    public R queryByPage(@RequestBody StudentQuestionTagWeightsDto dto, HttpServletRequest request) {
        return R.ok(studentQuestionTagWeightsService.queryByPage(dto));
    }
    /**
     * 分页查询
     *
     * @param dto 筛选条件
     * @return 查询结果
     */
    @ApiOperation(value = "分页查询学生权重")
    @PostMapping("/queryStuWeitsByPage")
    @ApiResponses({
            @ApiResponse(code = 200, message = "OK", response = StudentQuestionTagWeightsVO.class),
    })
    public R queryStuWeitsByPage(@RequestBody StudentQuestionTagWeightsDto dto, HttpServletRequest request) {
        return R.ok(studentQuestionTagWeightsService.queryStuWeitsByPage(dto));
    }

    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @ApiOperation(value = "主键查询")
    @GetMapping("/queryById")
    public R<?> queryById(@RequestParam("id") Integer id) {
        return R.ok(studentQuestionTagWeightsService.queryByStuId(id));
    }

    /**
     * 新增数据
     *
     * @param studentQuestionTagWeights 实体
     * @return 新增结果
     */
    @ApiOperation(value = "新增数据")
    @PostMapping("/save")
    public R<StudentQuestionTagWeights> add(@RequestBody StudentQuestionTagWeights studentQuestionTagWeights) {
        return R.ok(studentQuestionTagWeightsService.insert(studentQuestionTagWeights));
    }

    /**
     * 编辑数据
     *
     * @param studentQuestionTagWeights 实体
     * @return 编辑结果
     */
    @ApiOperation(value = "编辑数据")
    @PostMapping("/update")
    public R<StudentQuestionTagWeights> edit(@RequestBody StudentQuestionTagWeights studentQuestionTagWeights) {
        return R.ok(studentQuestionTagWeightsService.update(studentQuestionTagWeights));
    }

    /**
     * 删除数据
     *
     * @param id 主键
     * @return 删除是否成功
     */
    @GetMapping("/deleteById")
    @ApiOperation(value = "删除数据")
    public R<Boolean> deleteById(@RequestParam("id") Integer id) {
        return R.ok(studentQuestionTagWeightsService.deleteById(id));
    }

}

